                <!-- table -->
				<div class="box">
					<!-- box / title -->
					<div class="title">
						<h5>
                            <?=$title;?>
                            <?php 
                                if($tomonth!='-')
                                    print month_name($month).' '.$year;
                            ?>
                        </h5>
						<div class="search">
                            <?php if($tomonth=='-'): ?>
                            <?=form_open('cashflow/administrator/getBudgetDepartment')?>
								<div class="input">
                                    <?=form_dropdown('to_month',config('to_month'),'','style="width:60px"')?>
                                    <?=form_dropdown('month',config('month'),date('m'),$month)?>
								</div>
                                <div class="input">
									<?=form_dropdown('year',config('year'),date('Y'),$month)?>
								</div>
                                <div class="input">
									<?=form_dropdown('department',$departement,$dep,'style="width:120px"')?>
								</div>
                                <div class="input">
									<?=form_dropdown('type',config('type'),$type,'style="width:65px"')?>
								</div>
                                <div class="input">
                                    <?php if(empty($account))
                                         $account = '';
                                    ?>
									<?=form_dropdown('budget',$budget,$account,'style="width:120px"')?>
								</div>
								<div class="button">
									<input type="submit" name="submit" value="Search" />
								</div>
							<?=form_close()?>
                            <?php else:?>
                                <?=form_open('cashflow/administrator/getBudgetDepartmentExport')?>
								<div class="input">
                                    <label class="search"><?=lang('export')?></label>
									<?=form_dropdown('export',config('export'))?>
								</div>
								<div class="button">
									<?=form_submit('submit',lang('export'))?>
								</div>
							     <?=form_close()?>
                            <?php endif;?>
						</div>
					</div>
					<!-- end box / title -->
					<div class="table">
						<table>
							<thead>
								<tr>
									<th><?=lang('coa')?></th>
                                    <th><?=lang('ikhtisar')?></th>
                                    <th><?=lang('budget')?></th>
                                    <th><?=lang('planning')?></th>
                                    <th><?=lang('realitation')?></th>
                                    <th><?=lang('deviation')?></th>
                                    <th><?=lang('over')?></th>
                                    <th><?='(%)'?></th>
								</tr>
                                
							</thead>
							<tbody>
                                <?php 
                                      $t3 = 0;
                                      foreach($coa as $coa):?>
                                <?php $data = $this->budgets->getBudgetSet($year,$month,'',$dep,'',substr($coa['NoUrut'],0,3)); ?>
                                <?php if($data['AR']>0):?>
                                <tr>
                                    <td><?=$coa['NoUrut']?></td>
                                    <td><b><?=$coa['Ikhtisar']?></b></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                
                                <?php $query = $this->budgets->getBudgetAccount(substr($coa['NoUrut'],0,3));?>
                                <?php 
                                    $anggaran = 0 ;
                                    $rencana = 0;
                                    $realisasi = 0;
                                    $deviasi = 0;
                                    $over_budget=0;
                                    foreach($query as $acc):?>
                                <?php 
                                    $budget =   $this->budgets->getBudgetSet($year,$month,$acc['MataAnggaran'],$dep);
                                    $cash   =   $this->cashflow->getBudgetCashflow($year,$month,$acc['MataAnggaran'],$dep);
                                    $over   =   $budget['tAnggaran'] - $cash['Credit'];
                                    $t3     =   $over;         
                                ?>
                                <?php if($over != 0): ?>
                                <tr>
                                    <td><?=$acc['MataAnggaran']?></td>
                                    <td><?=$acc['Ikhtisar']?></td>
                                    <td>
                                    <?php if(!empty($budget['tAnggaran'])): 
                                                echo decimal($budget['tAnggaran'],2);
                                                $a = $budget['tAnggaran']; 
                                          else:
                                                echo '0.00';
                                                $a=0;
                                          endif;            
                                                
                                          $anggaran = $anggaran + $a;    
                                    ?>
                                    </td>
                                    <td class="right">
                                    <?php if(!empty($budget['Anggaran'])): 
                                                echo decimal($budget['Anggaran'],2);
                                                $b = $budget['Anggaran'];
                                          else:
                                                echo '0.00';
                                                $b = 0;
                                          endif;  
                                          $rencana = $rencana + $b;          
                                    ?>
                                    </td>
                                    <td class="right">
                                    <?php if(!empty($cash['Credit'])): 
                                                echo decimal($credit = $cash['Credit'],2);
                                                $c = $cash['Credit'];
                                          else:
                                                echo '0.00';
                                                $c = 0;
                                          endif;      
                                                
                                          $realisasi=    $realisasi+$c;        
                                                
                                    ?>
                                    </td>
                                    <td class="right">
                                    <?php 
                                        $dev = $budget['Anggaran'] - $cash['Credit'];
                                        if(!empty($dev)):
                                            echo decimal($dev,2);
                                            $d = $dev;
                                        else:
                                            echo '0.00'; 
                                            $d = 0;
                                        endif;  
                                        $deviasi =    $deviasi+$d;      
                                    ?>
                                    </td>
                                    <td class="right">
                                    <?php 
                                        if(!empty($over)):
                                            echo decimal($over,2);
                                        else:
                                            echo '0,00';
                                            $over = 0;
                                        endif; 
                                        $over_budget = $over_budget + $over;       
                                    ?>
                                    </td>
                                    <td class="right">
                                    <?php 
                                        if(($acc['Jenis']=='D')):
                                            if($budget['tAnggaran']==0)
                                                $percent = 0;
                                            else
                                                $percent = ($cash['Credit']/$budget['tAnggaran'])*100;
                                        endif;
                                        
                                        if(!empty($percent))
                                            echo decimal($percent,2);
                                        else echo '0.00';      
                                    ?>
                                    </td>
                                </tr>
                                <?php endif;?>
                                <?php endforeach;?>
                                <?php
                                    $footer = $this->budgets->getBudgetFooter(substr($coa['NoUrut'],0,3));
                                ?>
                                <?php if($footer): ?>
                                <tr>
                                    <th></th>
                                    <th class="left"><?=$footer['Ikhtisar']?></th>
                                    <th class="right"><?=decimal($anggaran,2)?></th>
                                    <th class="right"><?=decimal($rencana,2)?></th>
                                    <th class="right"><?=decimal($realisasi,2)?></th>
                                    <th class="right"><?=decimal($deviasi,2)?></th>
                                    <th class="right"><?=decimal($over_budget,2)?></th>
                                    <th class="right">
                                    <?php 
                                        
                                        $tot_percent =($realisasi/$anggaran)*100;
                                        echo decimal($tot_percent,2);
                                    ?>
                                    </th>
                                </tr>
                                <?php endif;?> 
                                <?php endif;?>   
                                <?php endforeach;?>
                                <?php
                                    $footer2 = $this->budgets->getBudgetFooter2();
                                    
                                ?>
                                <?php if($footer2): ?>
                                <tr>
                                    <th></th>
                                    <th class="left"><?=$footer2['Ikhtisar']?></th>
                                    <th class="right"></th>
                                    <th class="right"></th>
                                    <th class="right"></th>
                                    <th class="right"></th>
                                    <th class="right"></th>
                                    <th class="right">
                                    <?php 
                                        
                                        //$tot_percent =($realisasi/$anggaran)*100;
                                        //echo decimal($tot_percent,2);
                                    ?>
                                    </th>
                                </tr>
                                <?php endif;?> 
							</tbody>
						</table>
                        
                        <?php if($tomonth!='-'):?>
                        <div class="action">
                            <?=anchor('cashflow/administrator/getBudgetDepartmentReset','Kembali Ke Awal');?>
			         	</div>
                        <?php endif;?>
                        
					</div>
				</div>
				<!-- end table -->